<template>
	<view>
		<view v-if="dataObj.length === 0">
			<view class="padding-lr padding-bottom" style="margin-top: 10%;">
				<view class="padding-xs flex align-center">
					<view class="flex-sub text-center">
						<view class="solid-bottom text-xsl padding">
							<text class="cuIcon-warnfill text-gray"></text>
						</view>
						<view class="padding">暂无预约记录</view>
					</view>
				</view>
			</view>
		</view>
		<view class="content-wrap" v-else v-for="(item,index) in dataObj" :key="index">
			<view class="content-item margin bg-white shadow padding radius">
				<view class="solid-bottom">
					<view class="text-left text-xl padding-top">申请时间：{{item.createTime}}</view>
					<view class="text-left text-xl padding-top-lg">随行人数：{{item.peopleNum}}</view>
					<view class="text-left text-xl padding-top-lg">入校时间：{{item.time}}</view>
					<view class="text-left text-xl padding-tb-lg">入校事由：{{item.reason || ""}}</view>
				</view>
				<view class="text-left text-xl padding-top">申请状态：
					<text class="text-red"> {{ getStatus(item.status) }}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		reservation_records
	} from '@/common/api/api.js'

	export default {
		computed: {
			aa(e) {
				return this.getStatus(e)
			}
		},
		data() {
			return {
				loadStatus: 'loadmore',
				params: {
					pageNo: 1,
					pageSize: 10
				},
				dataObj: [{
					createTime: "-",
					peopleNum: "-",
					time: "-",
					reason: "-",
					status_dict: "-"
				}]
			};
		},
		onLoad() {
			this.getData()
		},
		methods: {
			getStatus(e) {
				let status_dict = "";
				let a = [{
					code: -1,
					text: "审核不通过"
				}, {
					code: 0,
					text: "审核中"
				}, {
					code: 1,
					text: "审核通过"
				}]
				a.forEach(item => {
					if (item.code === e) {
						status_dict = item.text
					}
				})
				return status_dict
			},
			getData() {
				// this.loadStatus = 'loading'
				reservation_records().then(res => {
					let records = this.$s.res(res).records
					if (records && records.length > 0) {
						this.dataObj = records
					}
				}).catch(err => {
					// this.loadStatus = 'loadmore'
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content-item {
		border-radius: 10px;
		border-top: 12px solid rgb(229, 77, 66);
	}
</style>